#include <allegro.h>
#include <stdlib.h>
#include <unistd.h>
#include "chargement.h"
#include "collision.h"
#include "affichage.h"





void Affichage( perso p,ennem e, bon b,cartouche *c,vie *v , background bg , BITMAP *buffer , int score )
{
	clear(buffer);
 	//draw_sprite(buffer, bg.back_ground,0,bg.by-110);
    draw_sprite(buffer, bg.background,bg.bh,0);
      if ( p.pos_jump ==2 ) {draw_sprite(buffer,p.jumpr  ,p.x,p.y );  } //charger dans la mémoire
    else
     if ( p.pos_jump ==1 ) {draw_sprite(buffer,p.jumpl  ,p.x,p.y );  }
     else
        if (  p.pos ==1  )
    {
	draw_sprite(buffer,p.img_right[p.i%3]  ,p.x,p.y );
	}else
	if ( p.pos ==-1 )
    {
	draw_sprite(buffer,p.img_left[p.j%3]  ,p.x,p.y );
	}
     if (e.pos ==1  )
    {
	draw_sprite(buffer,e.img_right[e.j%3]  ,e.x,e.y );
	}
	if ( e.pos ==-1 )
    {
	draw_sprite(buffer,e.img_left[e.i%3]  ,e.x,e.y );
	}
    if (c->xx==1) { c->x=c->x+5;c->xxx=c->xxx+5 ; draw_sprite(buffer,c->img_cart ,c->x,c->y );}
    if (c->xx==-1) { c->x=c->x-5;c->xxx=c->xxx+5; draw_sprite(buffer,c->img_cart ,c->x,c->y ); }
	draw_sprite(buffer,v->img_vie[v->pourcentage]  ,100,100 );
	if ( v->pourcentage == 0 )
        {
            v->pourcentage=10 ;
            v->nobmre_de_vie  -- ;
        }
        if ( v->pourcentage == 10 )
        {
            v->pourcentage=1 ;
            v->nobmre_de_vie  ++ ;
        }


        draw_sprite(buffer,b.img_bonus  ,b.x,b.y );
//        draw_spric.te(buffer,bonus  ,b2.x,b2.y );
//          draw_spric.te(buffer,bonus  ,b3.x,b3.y );
        if ( v->nobmre_de_vie  ==0 )
        {
         textprintf_centre_ex(buffer, font, 400,50,makecol(255, 0 ,0), -1,"dsl vous aver perdu");
        }
        textprintf_centre_ex(buffer, font, 750,50,makecol(255, 0 ,0), -1,"nobmre_de_vie  : %d",v->nobmre_de_vie );

/*Affichage du Score*/
      textprintf_centre_ex(buffer, font, 900,50,makecol(255, 245 ,238), +1,"score : %d",score);
       
	blit(buffer,screen,0,0,0,0,1300,700);
}

